<template>
  <el-dialog
    v-el-drag-dialog
    title="隐患告知书 "
    :visible.sync="visible"
    :append-to-body="true"
    width="800px"
    @closed="reset"
  >
    <div>
      <div class="info-item">
        <div class="info-item-label">安检客户：</div>
        <div class="info-item-content">{{ detailInfo.csmName }}({{ detailInfo.csmCode }})</div>
      </div>
      <div class="info-item">
        <div class="info-item-label">安检时间：</div>
        <div class="info-item-content">{{ detailInfo.checkDt && parseTime(detailInfo.checkDt, '{y}-{m}-{d} {h}:{i}:{s}') }}</div>
      </div>
      <div class="info-item">
        <div class="info-item-label">安检地址：</div>
        <div class="info-item-content">{{ detailInfo.csmAddress }}</div>
      </div>
      <div class="info-item">
        <div class="info-item-label">隐患告知内容：</div>
        <div class="info-item-content">
          <div v-for="(item, index) in detailInfo.billItemList" :key="index" class="warnItem">
            <p style="margin-bottom: 5px;"><span>{{ item.itemName }}</span><span>({{ item.itemDetailName }})</span></p>
            <div>建议措施：{{ item.adviseRemark }}</div>
          </div>
        </div>
      </div>
      <img v-if="detailInfo.cmSignPict" class="csmSign" :src="cmSignPict" alt="">
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { parseTime } from '@/utils'
  import { imgBaseUrl } from '@/utils/config'
  import { queryWarningNoticeData } from '@/api'

  export default {
    name: 'hazardNotice',
    data() {
      return {
        parseTime,
        visible: false,
        detailInfo: {}
      }
    },
    computed: {
      cmSignPict() {
        return this.detailInfo.cmSignPict ? imgBaseUrl + this.detailInfo.cmSignPict : ''
      }
    },
    methods: {
      open(temp) {
        this.visible = true
        if (temp) {
          this.getWarningNoticeData({ checkId: temp.checkId })
        }
      },
      async getWarningNoticeData(params) {
        const res = await queryWarningNoticeData(params)
        if (res && res.data) {
          this.detailInfo = res.data
        }
      },
      reset() {
        this.detailInfo = {}
      }
    }
  }
</script>
<style lang="scss" scoped>
  .info-item {
    display: flex;
    margin-bottom: 10px;
    &-label {
      font-weight: 700;
    }
  }
  .csmSign {
    width: 150px;
    height: 180px;
  }
  .warnItem {
    p > span {
      margin-right: 10px;
    }
  }
</style>
